# -*- coding: utf-8 -*-

import logging

from sqlalchemy import create_engine
from sqlalchemy.engine import Engine  # noqa
from sqlalchemy.orm import sessionmaker, Session

from py_global import db_url

logger = logging.getLogger(__name__)

engine: Engine = create_engine(
    db_url,
    pool_size=2,
    pool_recycle=30,
    pool_timeout=30,
    pool_pre_ping=True,
    max_overflow=0,
)

# engine.echo = True  # 日志


_Session = sessionmaker(bind=engine)
session: Session = _Session()
